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

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

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

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

k = A("k")
j = B("j")
b = C("b")
e = D("e")
a = B("a")

k.r = a
k.o = a
k.x = e
j.y = e
j.s = e
j.r = e
j.o = b
b.u = k
e.o = k
a.y = e
a.s = e
a.r = e
a.o = b
assert b.u.x.o.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.x: D = None
        self.o: B = None
        self.txt = txt

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

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

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

k = A("k")
j = B("j")
b = C("b")
e = D("e")
a = B("a")

k.r = a
k.o = a
k.x = e
j.y = e
j.s = e
j.r = e
j.o = b
b.u = k
e.o = k
a.y = e
a.s = e
a.r = e
a.o = b
assert b.u.x.o.x.o.txt == "k"