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

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

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

h = A("h")
g = B("g")
b = C("b")
c = B("c")
f = A("f")
e = C("e")

h.x = c
h.v = c
h.p = f
g.t = e
g.o = h
g.q = c
b.p = f
c.t = e
c.o = h
c.q = g
f.x = g
f.p = h
f.v = c
e.p = h
assert g.t.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.p: A = None
        self.v: B = None
        self.txt = txt

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

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

h = A("h")
g = B("g")
b = C("b")
c = B("c")
f = A("f")
e = C("e")

h.x = c
h.v = c
h.p = f
g.t = e
g.o = h
g.q = c
b.p = f
c.t = e
c.o = h
c.q = g
f.x = g
f.p = h
f.v = c
e.p = h
assert g.t.p.v.txt == "c"