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

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

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

i = A("i")
b = B("b")
d = C("d")
n = A("n")
j = A("j")
c = C("c")

i.t = j
i.u = j
i.p = n
b.v = d
b.o = c
d.r = c
n.t = i
n.p = i
n.u = j
j.t = n
j.p = i
j.u = i
c.r = d
assert d.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.p: A = None
        self.u: A = None
        self.txt = txt

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

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

i = A("i")
b = B("b")
d = C("d")
n = A("n")
j = A("j")
c = C("c")

i.t = j
i.u = j
i.p = n
b.v = d
b.o = c
d.r = c
n.t = i
n.p = i
n.u = j
j.t = n
j.p = i
j.u = i
c.r = d
assert d.r.r.r.r.r.txt == "c"