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

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

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

g = A("g")
n = B("n")
b = C("b")
d = A("d")
m = B("m")
j = C("j")

g.q = j
g.o = m
n.x = m
n.v = j
b.v = j
b.u = j
d.q = j
d.o = n
m.x = n
m.v = j
j.v = b
j.u = b
assert m.v.u.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.o: B = None
        self.txt = txt

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

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

g = A("g")
n = B("n")
b = C("b")
d = A("d")
m = B("m")
j = C("j")

g.q = j
g.o = m
n.x = m
n.v = j
b.v = j
b.u = j
d.q = j
d.o = n
m.x = n
m.v = j
j.v = b
j.u = b
assert m.v.u.u.v.txt == "b"