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

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

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

c = A("c")
j = B("j")
g = C("g")
h = A("h")

c.v = g
c.p = j
j.y = g
j.t = g
j.o = h
g.v = c
h.v = g
h.p = j
assert g.v.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.p: B = None
        self.txt = txt

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

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

c = A("c")
j = B("j")
g = C("g")
h = A("h")

c.v = g
c.p = j
j.y = g
j.t = g
j.o = h
g.v = c
h.v = g
h.p = j
assert g.v.p.o.txt == "h"