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

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

i = A("i")
b = B("b")
c = A("c")
e = A("e")
k = A("k")
n = B("n")
d = B("d")
a = A("a")
h = B("h")
f = B("f")

i.y = k
i.o = f
b.p = k
c.y = a
c.o = f
e.y = a
e.o = d
k.y = c
k.o = h
n.p = e
d.p = i
a.y = i
a.o = h
h.p = e
f.p = c
assert c.o.p.y.y.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: B = None
        self.txt = txt

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

i = A("i")
b = B("b")
c = A("c")
e = A("e")
k = A("k")
n = B("n")
d = B("d")
a = A("a")
h = B("h")
f = B("f")

i.y = k
i.o = f
b.p = k
c.y = a
c.o = f
e.y = a
e.o = d
k.y = c
k.o = h
n.p = e
d.p = i
a.y = i
a.o = h
h.p = e
f.p = c
assert c.o.p.y.y.o.p.txt == "c"