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

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

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

f = A("f")
g = B("g")
c = C("c")
l = C("l")
i = C("i")
d = A("d")
m = B("m")
a = B("a")
h = B("h")
k = C("k")

f.p = d
f.o = k
g.u = d
c.q = k
c.x = d
c.u = l
l.q = c
l.u = c
l.x = d
i.q = k
i.u = k
i.x = d
d.p = f
d.o = c
m.u = f
a.u = d
h.u = f
k.q = c
k.u = c
k.x = f
assert k.x.o.q.x.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.o: C = None
        self.txt = txt

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

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

f = A("f")
g = B("g")
c = C("c")
l = C("l")
i = C("i")
d = A("d")
m = B("m")
a = B("a")
h = B("h")
k = C("k")

f.p = d
f.o = k
g.u = d
c.q = k
c.x = d
c.u = l
l.q = c
l.u = c
l.x = d
i.q = k
i.u = k
i.x = d
d.p = f
d.o = c
m.u = f
a.u = d
h.u = f
k.q = c
k.u = c
k.x = f
assert k.x.o.q.x.p.o.txt == "k"