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

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

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

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.u: B = None
        self.s: B = None
        self.txt = txt

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

n = A("n")
c = B("c")
h = C("h")
j = D("j")
f = E("f")
g = E("g")
a = E("a")

n.t = c
c.p = g
h.o = j
h.p = j
j.q = n
j.u = c
j.s = c
f.t = n
g.t = n
a.t = n
assert c.p.t.t.p.t.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.u: B = None
        self.s: B = None
        self.txt = txt

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

n = A("n")
c = B("c")
h = C("h")
j = D("j")
f = E("f")
g = E("g")
a = E("a")

n.t = c
c.p = g
h.o = j
h.p = j
j.q = n
j.u = c
j.s = c
f.t = n
g.t = n
a.t = n
assert c.p.t.t.p.t.t.p.txt == "g"