class A:
    def __init__(self, txt: str):
        self.u: 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: C = None
        self.o: C = None
        self.txt = txt

f = A("f")
g = B("g")
n = C("n")
b = C("b")
c = B("c")

f.u = c
g.v = c
n.q = b
n.o = b
b.q = n
b.o = n
c.v = g
assert f.u.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: 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: C = None
        self.o: C = None
        self.txt = txt

f = A("f")
g = B("g")
n = C("n")
b = C("b")
c = B("c")

f.u = c
g.v = c
n.q = b
n.o = b
b.q = n
b.o = n
c.v = g
assert f.u.v.v.v.v.txt == "c"