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

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

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

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

m = A("m")
j = B("j")
i = C("i")
e = D("e")
a = C("a")
n = D("n")
c = A("c")
b = D("b")

m.o = e
m.t = c
m.x = i
j.o = n
i.x = b
i.u = m
e.p = a
e.q = c
e.u = i
e.r = m
a.x = n
a.u = c
n.p = a
n.u = a
n.q = c
n.r = m
c.o = b
c.t = m
c.x = a
b.p = a
b.u = a
b.q = c
b.r = c
assert m.t.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.t: A = None
        self.x: C = None
        self.txt = txt

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

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

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

m = A("m")
j = B("j")
i = C("i")
e = D("e")
a = C("a")
n = D("n")
c = A("c")
b = D("b")

m.o = e
m.t = c
m.x = i
j.o = n
i.x = b
i.u = m
e.p = a
e.q = c
e.u = i
e.r = m
a.x = n
a.u = c
n.p = a
n.u = a
n.q = c
n.r = m
c.o = b
c.t = m
c.x = a
b.p = a
b.u = a
b.q = c
b.r = c
assert m.t.t.x.txt == "i"