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

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

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

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

d = A("d")
k = B("k")
j = C("j")
b = D("b")
a = A("a")
i = B("i")
l = B("l")
c = C("c")
h = C("h")

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

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

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

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

d = A("d")
k = B("k")
j = C("j")
b = D("b")
a = A("a")
i = B("i")
l = B("l")
c = C("c")
h = C("h")

d.u = b
d.r = b
d.t = a
k.x = i
k.v = d
j.r = b
b.z = c
b.t = h
b.p = h
b.r = a
a.u = b
a.r = b
a.t = d
i.x = l
i.v = d
l.x = k
l.v = a
c.r = b
h.r = b
assert a.t.r.z.r.txt == "b"