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

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

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

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

g.x = n
g.u = n
g.p = f
d.u = k
d.o = f
b.q = n
k.u = d
k.o = f
f.q = g
l.u = k
l.o = b
n.x = g
n.u = g
n.p = f
assert k.u.u.o.q.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.p: C = None
        self.u: A = None
        self.txt = txt

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

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

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

g.x = n
g.u = n
g.p = f
d.u = k
d.o = f
b.q = n
k.u = d
k.o = f
f.q = g
l.u = k
l.o = b
n.x = g
n.u = g
n.p = f
assert k.u.u.o.q.p.q.txt == "g"