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

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

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

c = A("c")
f = B("f")
e = C("e")
h = C("h")
j = A("j")
n = A("n")
k = A("k")

c.u = j
c.y = j
f.p = h
e.u = f
e.o = h
h.u = f
h.o = e
j.u = c
j.y = c
n.u = k
n.y = k
k.u = j
k.y = j
assert f.p.u.p.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.y: A = None
        self.txt = txt

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

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

c = A("c")
f = B("f")
e = C("e")
h = C("h")
j = A("j")
n = A("n")
k = A("k")

c.u = j
c.y = j
f.p = h
e.u = f
e.o = h
h.u = f
h.o = e
j.u = c
j.y = c
n.u = k
n.y = k
k.u = j
k.y = j
assert f.p.u.p.o.o.txt == "h"