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

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

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

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

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

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

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

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

c.o = h
e.v = h
g.q = c
g.x = h
h.v = e
a.v = e
assert g.x.v.v.txt == "h"