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

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

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

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

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

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

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

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

m.x = a
i.p = m
i.r = f
i.t = f
c.p = m
c.v = a
c.q = j
f.p = m
f.r = i
f.t = i
a.p = m
a.v = j
a.q = j
j.p = m
j.v = c
j.q = c
assert j.q.v.v.p.x.txt == "a"