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

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

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

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

l = A("l")
a = B("a")
g = C("g")
b = D("b")
d = C("d")
c = D("c")
f = A("f")
j = D("j")

l.t = c
l.x = c
l.r = g
a.y = d
a.q = l
a.r = l
g.o = f
g.x = f
g.r = c
b.z = g
b.q = c
d.o = f
d.r = b
d.x = l
c.z = d
c.q = j
f.t = b
f.x = j
f.r = d
j.z = d
j.q = b
assert c.q.q.q.q.z.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.x: D = None
        self.r: C = None
        self.txt = txt

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

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

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

l = A("l")
a = B("a")
g = C("g")
b = D("b")
d = C("d")
c = D("c")
f = A("f")
j = D("j")

l.t = c
l.x = c
l.r = g
a.y = d
a.q = l
a.r = l
g.o = f
g.x = f
g.r = c
b.z = g
b.q = c
d.o = f
d.r = b
d.x = l
c.z = d
c.q = j
f.t = b
f.x = j
f.r = d
j.z = d
j.q = b
assert c.q.q.q.q.z.o.r.txt == "d"