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

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

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

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

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

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

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

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

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

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

a.y = k
k.x = b
g.v = b
g.q = b
b.p = g
b.o = a
assert a.y.x.p.txt == "g"