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

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

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

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

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

c.u = m
b.q = c
b.o = c
b.u = e
b.t = m
e.y = m
e.u = m
e.v = b
e.p = b
m.r = e
m.o = b
assert b.u.v.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

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

c.u = m
b.q = c
b.o = c
b.u = e
b.t = m
e.y = m
e.u = m
e.v = b
e.p = b
m.r = e
m.o = b
assert b.u.v.u.y.txt == "m"