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

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

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

e = A("e")
g = B("g")
f = C("f")
d = C("d")
k = C("k")
m = C("m")
n = A("n")
j = B("j")
l = C("l")
b = C("b")

e.q = n
e.x = n
e.y = j
g.x = j
f.o = e
d.o = n
k.o = e
m.o = e
n.q = e
n.x = e
n.y = g
j.x = g
l.o = n
b.o = n
assert e.x.y.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: A = None
        self.y: B = None
        self.txt = txt

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

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

e = A("e")
g = B("g")
f = C("f")
d = C("d")
k = C("k")
m = C("m")
n = A("n")
j = B("j")
l = C("l")
b = C("b")

e.q = n
e.x = n
e.y = j
g.x = j
f.o = e
d.o = n
k.o = e
m.o = e
n.q = e
n.x = e
n.y = g
j.x = g
l.o = n
b.o = n
assert e.x.y.x.x.x.x.x.x.txt == "g"