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

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

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

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

b = A("b")
g = B("g")
m = C("m")
c = D("c")
j = B("j")
e = D("e")

b.u = m
b.z = m
b.r = j
g.z = c
g.r = c
g.t = c
m.t = b
m.y = c
c.z = j
c.p = b
j.z = e
j.t = e
j.r = c
e.z = j
e.p = b
assert b.z.y.p.r.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.r: B = None
        self.z: C = None
        self.txt = txt

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

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

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

b = A("b")
g = B("g")
m = C("m")
c = D("c")
j = B("j")
e = D("e")

b.u = m
b.z = m
b.r = j
g.z = c
g.r = c
g.t = c
m.t = b
m.y = c
c.z = j
c.p = b
j.z = e
j.t = e
j.r = c
e.z = j
e.p = b
assert b.z.y.p.r.t.p.txt == "b"