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

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

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

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

j.u = k
l.y = g
l.p = c
l.z = c
c.s = g
c.o = l
a.y = l
a.p = c
a.z = c
k.u = j
g.y = a
g.p = c
g.z = c
assert j.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

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

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

j.u = k
l.y = g
l.p = c
l.z = c
c.s = g
c.o = l
a.y = l
a.p = c
a.z = c
k.u = j
g.y = a
g.p = c
g.z = c
assert j.u.u.u.u.txt == "j"