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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

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

j.x = c
j.q = d
i.x = b
f.s = j
f.o = j
f.q = e
f.p = c
b.z = j
c.z = j
h.x = c
d.x = c
d.q = j
k.x = b
e.x = b
g.x = c
assert e.x.z.q.x.z.x.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

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

j.x = c
j.q = d
i.x = b
f.s = j
f.o = j
f.q = e
f.p = c
b.z = j
c.z = j
h.x = c
d.x = c
d.q = j
k.x = b
e.x = b
g.x = c
assert e.x.z.q.x.z.x.z.q.txt == "d"