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

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

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

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

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

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

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

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

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