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

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

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

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

l = A("l")
g = B("g")
b = C("b")
j = D("j")

l.o = g
l.t = g
l.y = b
l.q = j
g.r = j
b.y = l
b.s = l
b.o = j
b.u = j
j.y = l
assert j.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: C = None
        self.t: B = None
        self.q: D = None
        self.txt = txt

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

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

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

l = A("l")
g = B("g")
b = C("b")
j = D("j")

l.o = g
l.t = g
l.y = b
l.q = j
g.r = j
b.y = l
b.s = l
b.o = j
b.u = j
j.y = l
assert j.y.y.y.txt == "l"