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

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

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

j = A("j")
g = B("g")
a = C("a")
c = B("c")
m = B("m")
f = C("f")

j.p = a
g.x = m
g.v = a
g.u = a
a.t = f
c.x = m
c.v = a
c.u = a
m.x = g
m.v = a
m.u = f
f.t = a
assert f.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

j = A("j")
g = B("g")
a = C("a")
c = B("c")
m = B("m")
f = C("f")

j.p = a
g.x = m
g.v = a
g.u = a
a.t = f
c.x = m
c.v = a
c.u = a
m.x = g
m.v = a
m.u = f
f.t = a
assert f.t.t.t.t.t.t.txt == "f"