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

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

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

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

c = A("c")
a = B("a")
d = C("d")
k = D("k")
m = D("m")
n = D("n")
b = B("b")
g = D("g")
e = D("e")

c.y = e
a.o = d
d.t = b
k.v = a
k.q = d
k.o = d
m.v = b
m.q = d
m.o = d
n.v = a
n.q = d
n.o = d
b.o = d
g.v = a
g.q = d
g.o = d
e.v = b
e.q = d
e.o = d
assert b.o.t.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

c = A("c")
a = B("a")
d = C("d")
k = D("k")
m = D("m")
n = D("n")
b = B("b")
g = D("g")
e = D("e")

c.y = e
a.o = d
d.t = b
k.v = a
k.q = d
k.o = d
m.v = b
m.q = d
m.o = d
n.v = a
n.q = d
n.o = d
b.o = d
g.v = a
g.q = d
g.o = d
e.v = b
e.q = d
e.o = d
assert b.o.t.o.t.txt == "b"