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

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

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

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

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

a.p = d
a.s = k
k.o = a
c.t = d
c.r = a
g.u = j
g.x = k
g.z = a
j.u = g
j.x = k
j.z = a
d.t = l
d.r = a
l.t = d
l.r = a
assert a.p.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.s: B = None
        self.txt = txt

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

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

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

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

a.p = d
a.s = k
k.o = a
c.t = d
c.r = a
g.u = j
g.x = k
g.z = a
j.u = g
j.x = k
j.z = a
d.t = l
d.r = a
l.t = d
l.r = a
assert a.p.t.t.t.txt == "l"