class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.q: A = None
        self.o: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.u: D = None
        self.t: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.r: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: A = None
        self.y: A = None
        self.z: D = None
        self.txt = txt

d = A("d")
c = B("c")
g = C("g")
h = D("h")
f = C("f")
e = D("e")
b = A("b")
k = B("k")

d.z = f
d.q = b
d.o = e
c.q = b
c.u = e
c.t = e
g.q = d
g.r = d
h.q = k
h.w = b
h.y = d
h.z = e
f.q = d
f.r = b
e.q = c
e.w = b
e.y = b
e.z = h
b.z = f
b.q = d
b.o = h
k.q = d
k.u = e
k.t = e
assert b.o.y.z.r.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.q: A = None
        self.o: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.u: D = None
        self.t: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.r: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: A = None
        self.y: A = None
        self.z: D = None
        self.txt = txt

d = A("d")
c = B("c")
g = C("g")
h = D("h")
f = C("f")
e = D("e")
b = A("b")
k = B("k")

d.z = f
d.q = b
d.o = e
c.q = b
c.u = e
c.t = e
g.q = d
g.r = d
h.q = k
h.w = b
h.y = d
h.z = e
f.q = d
f.r = b
e.q = c
e.w = b
e.y = b
e.z = h
b.z = f
b.q = d
b.o = h
k.q = d
k.u = e
k.t = e
assert b.o.y.z.r.o.z.txt == "e"