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

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

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

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

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

d.v = k
c.p = n
n.r = f
n.z = f
n.t = k
n.u = c
f.r = d
f.u = d
f.t = c
k.r = f
k.z = f
k.t = n
k.u = c
assert c.p.u.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

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

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

d.v = k
c.p = n
n.r = f
n.z = f
n.t = k
n.u = c
f.r = d
f.u = d
f.t = c
k.r = f
k.z = f
k.t = n
k.u = c
assert c.p.u.p.r.txt == "f"