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

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

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

i = A("i")
n = B("n")
g = C("g")
f = C("f")
h = A("h")
m = B("m")
j = C("j")

i.r = m
i.p = m
i.t = m
n.u = f
g.y = n
g.o = f
f.y = n
f.o = j
h.r = n
h.t = n
h.p = m
m.u = g
j.y = m
j.o = f
assert m.u.y.u.y.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.p: B = None
        self.t: B = None
        self.txt = txt

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

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

i = A("i")
n = B("n")
g = C("g")
f = C("f")
h = A("h")
m = B("m")
j = C("j")

i.r = m
i.p = m
i.t = m
n.u = f
g.y = n
g.o = f
f.y = n
f.o = j
h.r = n
h.t = n
h.p = m
m.u = g
j.y = m
j.o = f
assert m.u.y.u.y.u.o.txt == "j"