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

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

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

a = A("a")
h = B("h")
b = C("b")
k = A("k")
f = B("f")
n = C("n")
m = B("m")
c = C("c")

a.t = f
a.v = m
h.u = a
h.q = f
b.v = h
b.x = m
k.t = f
k.v = h
f.u = a
f.q = h
n.v = m
n.x = h
m.u = a
m.q = f
c.v = h
c.x = f
assert a.t.q.u.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.v: B = None
        self.txt = txt

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

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

a = A("a")
h = B("h")
b = C("b")
k = A("k")
f = B("f")
n = C("n")
m = B("m")
c = C("c")

a.t = f
a.v = m
h.u = a
h.q = f
b.v = h
b.x = m
k.t = f
k.v = h
f.u = a
f.q = h
n.v = m
n.x = h
m.u = a
m.q = f
c.v = h
c.x = f
assert a.t.q.u.t.u.txt == "a"