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

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

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

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

g = A("g")
j = B("j")
k = C("k")
n = D("n")
d = B("d")

g.v = k
g.p = k
j.p = n
j.y = d
k.o = n
k.x = n
n.y = k
n.s = g
d.p = n
d.y = j
assert g.v.o.s.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.p: C = None
        self.txt = txt

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

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

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

g = A("g")
j = B("j")
k = C("k")
n = D("n")
d = B("d")

g.v = k
g.p = k
j.p = n
j.y = d
k.o = n
k.x = n
n.y = k
n.s = g
d.p = n
d.y = j
assert g.v.o.s.v.x.txt == "n"