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

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

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

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

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

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

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

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

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

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

k.t = d
b.y = k
g.x = m
g.q = k
g.u = b
g.o = c
m.o = d
d.o = m
f.x = m
f.q = c
f.u = b
f.o = k
h.t = d
c.t = d
assert m.o.o.o.o.txt == "m"