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

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

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

g = A("g")
e = B("e")
h = C("h")

g.v = h
g.x = h
e.v = h
h.p = g
h.u = g
assert g.x.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.x: C = None
        self.txt = txt

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

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

g = A("g")
e = B("e")
h = C("h")

g.v = h
g.x = h
e.v = h
h.p = g
h.u = g
assert g.x.p.v.txt == "h"