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

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

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

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

c = A("c")
f = B("f")
g = C("g")
n = D("n")

c.y = g
c.p = n
f.y = g
f.v = g
f.s = g
f.o = c
g.v = n
n.q = g
assert g.v.q.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: D = None
        self.txt = txt

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

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

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

c = A("c")
f = B("f")
g = C("g")
n = D("n")

c.y = g
c.p = n
f.y = g
f.v = g
f.s = g
f.o = c
g.v = n
n.q = g
assert g.v.q.v.q.txt == "g"