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

class B:
    def __init__(self, txt: str):
        self.r: B = None
        self.v: B = None
        self.txt = txt

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

c = A("c")
f = B("f")
h = C("h")
i = A("i")
j = C("j")
l = A("l")
d = B("d")
g = C("g")
a = A("a")
b = B("b")

c.p = l
f.r = d
f.v = d
h.u = d
h.w = f
i.p = a
j.u = b
j.w = f
l.p = c
d.r = f
d.v = b
g.u = f
g.w = b
a.p = c
b.r = d
b.v = d
assert a.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: B = None
        self.v: B = None
        self.txt = txt

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

c = A("c")
f = B("f")
h = C("h")
i = A("i")
j = C("j")
l = A("l")
d = B("d")
g = C("g")
a = A("a")
b = B("b")

c.p = l
f.r = d
f.v = d
h.u = d
h.w = f
i.p = a
j.u = b
j.w = f
l.p = c
d.r = f
d.v = b
g.u = f
g.w = b
a.p = c
b.r = d
b.v = d
assert a.p.p.p.txt == "c"