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

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

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

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

h.u = f
h.t = f
h.o = c
g.p = h
g.w = f
c.q = f
k.p = f
k.w = f
b.q = h
f.u = h
f.t = h
f.o = b
assert c.q.u.o.q.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.t: A = None
        self.o: C = None
        self.txt = txt

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

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

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

h.u = f
h.t = f
h.o = c
g.p = h
g.w = f
c.q = f
k.p = f
k.w = f
b.q = h
f.u = h
f.t = h
f.o = b
assert c.q.u.o.q.o.q.txt == "h"