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

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

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

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

d = A("d")
l = B("l")
h = C("h")
k = D("k")
b = D("b")
f = C("f")
a = B("a")

d.v = f
d.t = k
l.x = a
l.u = b
l.p = b
l.z = d
h.y = a
h.u = a
k.r = l
b.r = a
f.y = l
f.u = l
a.x = l
a.u = k
a.p = k
a.z = d
assert l.x.p.r.x.x.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.t: D = None
        self.txt = txt

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

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

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

d = A("d")
l = B("l")
h = C("h")
k = D("k")
b = D("b")
f = C("f")
a = B("a")

d.v = f
d.t = k
l.x = a
l.u = b
l.p = b
l.z = d
h.y = a
h.u = a
k.r = l
b.r = a
f.y = l
f.u = l
a.x = l
a.u = k
a.p = k
a.z = d
assert l.x.p.r.x.x.z.v.txt == "f"