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

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

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

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

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

b.q = l
b.v = k
l.p = b
l.s = k
l.x = k
a.o = b
a.y = b
a.x = k
k.x = a
k.z = a
k.s = b
k.p = b
assert l.p.v.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: D = None
        self.txt = txt

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

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

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

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

b.q = l
b.v = k
l.p = b
l.s = k
l.x = k
a.o = b
a.y = b
a.x = k
k.x = a
k.z = a
k.s = b
k.p = b
assert l.p.v.x.x.txt == "k"