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

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

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.v: D = None
        self.s: D = None
        self.txt = txt

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

j = A("j")
k = B("k")
c = C("c")
a = D("a")

j.o = a
j.u = a
j.p = k
j.q = k
k.s = c
k.o = c
k.u = a
k.r = j
c.p = j
c.v = a
c.s = a
a.x = j
assert k.u.x.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.p: B = None
        self.u: D = None
        self.q: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.v: D = None
        self.s: D = None
        self.txt = txt

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

j = A("j")
k = B("k")
c = C("c")
a = D("a")

j.o = a
j.u = a
j.p = k
j.q = k
k.s = c
k.o = c
k.u = a
k.r = j
c.p = j
c.v = a
c.s = a
a.x = j
assert k.u.x.u.x.txt == "j"