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

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

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

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

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

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

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

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

h.t = e
h.o = d
j.t = d
j.o = l
k.p = d
k.y = e
f.t = h
f.o = k
e.t = f
e.o = d
d.p = k
d.y = f
l.p = k
l.y = h
n.t = l
n.o = d
assert h.t.t.o.y.t.o.txt == "k"