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

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

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

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

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

c.o = m
c.r = m
c.y = e
m.s = e
m.x = j
j.s = m
j.q = e
j.t = e
e.u = c
e.r = m
assert j.s.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.r: B = None
        self.y: D = None
        self.txt = txt

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

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

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

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

c.o = m
c.r = m
c.y = e
m.s = e
m.x = j
j.s = m
j.q = e
j.t = e
e.u = c
e.r = m
assert j.s.s.r.txt == "m"