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.x: D = None
        self.p: A = None
        self.txt = txt

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

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

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

d.u = k
n.r = d
n.p = d
n.x = i
a.p = n
a.y = d
i.t = k
i.r = d
c.t = i
c.r = d
k.t = i
k.r = d
assert k.t.r.u.r.u.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.x: D = None
        self.p: A = None
        self.txt = txt

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

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

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

d.u = k
n.r = d
n.p = d
n.x = i
a.p = n
a.y = d
i.t = k
i.r = d
c.t = i
c.r = d
k.t = i
k.r = d
assert k.t.r.u.r.u.txt == "k"