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

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

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

k = A("k")
b = B("b")
n = C("n")
a = A("a")
c = C("c")
d = A("d")

k.x = a
k.u = a
b.v = n
b.o = k
n.z = b
n.t = b
a.x = k
a.u = d
c.z = b
c.t = b
d.x = k
d.u = a
assert d.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.u: A = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
n = C("n")
a = A("a")
c = C("c")
d = A("d")

k.x = a
k.u = a
b.v = n
b.o = k
n.z = b
n.t = b
a.x = k
a.u = d
c.z = b
c.t = b
d.x = k
d.u = a
assert d.x.x.x.x.txt == "a"