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

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

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

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

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

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

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

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

j.v = k
k.z = j
d.p = k
d.x = j
d.o = n
n.p = k
n.x = j
n.o = d
assert j.v.z.v.z.txt == "j"