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

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

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

j = A("j")
f = B("f")
m = C("m")
b = C("b")
d = A("d")

j.t = m
j.y = m
j.v = f
f.p = d
m.u = b
m.w = b
m.t = j
b.u = m
b.w = m
b.t = j
d.t = b
d.y = b
d.v = f
assert f.p.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.y: C = None
        self.v: B = None
        self.txt = txt

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

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

j = A("j")
f = B("f")
m = C("m")
b = C("b")
d = A("d")

j.t = m
j.y = m
j.v = f
f.p = d
m.u = b
m.w = b
m.t = j
b.u = m
b.w = m
b.t = j
d.t = b
d.y = b
d.v = f
assert f.p.v.p.txt == "d"