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

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

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

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

l.o = g
h.u = g
h.t = g
g.o = h
g.v = h
assert g.v.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

l.o = g
h.u = g
h.t = g
g.o = h
g.v = h
assert g.v.u.v.txt == "h"