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

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

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

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

b = A("b")
j = B("j")
d = C("d")
m = D("m")
a = B("a")

b.t = m
b.u = m
j.u = b
j.w = b
j.r = d
j.y = m
d.x = m
d.u = a
m.o = b
m.r = j
m.p = a
a.u = b
a.w = b
a.r = d
a.y = m
assert b.u.p.r.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.u: D = None
        self.txt = txt

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

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

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

b = A("b")
j = B("j")
d = C("d")
m = D("m")
a = B("a")

b.t = m
b.u = m
j.u = b
j.w = b
j.r = d
j.y = m
d.x = m
d.u = a
m.o = b
m.r = j
m.p = a
a.u = b
a.w = b
a.r = d
a.y = m
assert b.u.p.r.x.o.txt == "b"