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

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

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

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

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

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

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

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

f.o = n
j.q = a
j.t = h
n.y = h
n.p = h
e.o = h
h.y = n
h.p = n
a.q = j
a.t = h
assert j.t.y.p.p.y.txt == "h"