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

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: D = None
        self.r: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.y: C = None
        self.t: C = None
        self.p: B = None
        self.txt = txt

j = A("j")
i = B("i")
c = C("c")
n = D("n")
a = C("a")
e = D("e")

j.t = c
i.x = a
i.y = e
i.r = e
c.t = j
n.v = j
n.y = c
n.t = a
n.p = i
a.t = j
e.v = j
e.y = c
e.t = c
e.p = i
assert c.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: D = None
        self.r: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.y: C = None
        self.t: C = None
        self.p: B = None
        self.txt = txt

j = A("j")
i = B("i")
c = C("c")
n = D("n")
a = C("a")
e = D("e")

j.t = c
i.x = a
i.y = e
i.r = e
c.t = j
n.v = j
n.y = c
n.t = a
n.p = i
a.t = j
e.v = j
e.y = c
e.t = c
e.p = i
assert c.t.t.t.t.t.txt == "j"