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

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

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

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

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

d.u = i
n.r = d
n.u = d
i.v = e
i.t = e
a.u = n
e.v = i
e.t = i
assert n.u.u.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

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

d.u = i
n.r = d
n.u = d
i.v = e
i.t = e
a.u = n
e.v = i
e.t = i
assert n.u.u.v.v.txt == "i"