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

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

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

j = A("j")
a = B("a")
f = C("f")
d = A("d")
k = A("k")
m = C("m")

j.t = d
j.o = a
a.v = f
a.u = k
f.s = m
f.o = m
d.t = j
d.o = a
k.t = j
k.o = a
m.s = f
m.o = f
assert d.o.v.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.o: B = None
        self.txt = txt

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

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

j = A("j")
a = B("a")
f = C("f")
d = A("d")
k = A("k")
m = C("m")

j.t = d
j.o = a
a.v = f
a.u = k
f.s = m
f.o = m
d.t = j
d.o = a
k.t = j
k.o = a
m.s = f
m.o = f
assert d.o.v.o.o.o.o.txt == "f"