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

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

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

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

l = A("l")
m = B("m")
j = C("j")
f = D("f")
g = C("g")
a = B("a")

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

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

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

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

l = A("l")
m = B("m")
j = C("j")
f = D("f")
g = C("g")
a = B("a")

l.r = f
m.o = l
m.r = f
j.z = f
j.q = g
j.u = g
j.x = g
f.t = j
g.z = f
g.q = j
g.u = j
g.x = j
a.o = l
a.r = f
assert g.z.t.z.t.z.t.txt == "j"