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

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

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

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

n = A("n")
f = B("f")
k = C("k")
d = D("d")
c = D("c")
a = D("a")
j = A("j")

n.u = c
f.r = n
f.v = n
f.y = k
f.t = k
k.x = d
k.r = a
d.r = k
c.r = k
a.r = k
j.u = d
assert j.u.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

n = A("n")
f = B("f")
k = C("k")
d = D("d")
c = D("c")
a = D("a")
j = A("j")

n.u = c
f.r = n
f.v = n
f.y = k
f.t = k
k.x = d
k.r = a
d.r = k
c.r = k
a.r = k
j.u = d
assert j.u.r.r.r.r.txt == "a"