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

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

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

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

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

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

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

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

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

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

b.p = k
l.u = g
l.t = g
l.r = k
l.o = k
k.y = g
g.q = b
assert k.y.q.p.y.txt == "g"