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

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

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

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

d = A("d")
c = B("c")
g = C("g")
k = D("k")
e = B("e")

d.y = g
d.v = g
c.q = k
g.o = d
k.s = c
e.q = k
assert c.q.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.v: C = None
        self.txt = txt

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

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

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

d = A("d")
c = B("c")
g = C("g")
k = D("k")
e = B("e")

d.y = g
d.v = g
c.q = k
g.o = d
k.s = c
e.q = k
assert c.q.s.q.txt == "k"