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

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

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

l = A("l")
g = B("g")
f = C("f")
j = C("j")
a = B("a")
h = A("h")
m = C("m")
b = C("b")

l.r = h
l.p = h
l.v = g
g.o = a
g.z = a
g.r = h
f.w = l
j.w = l
a.o = g
a.z = g
a.r = h
h.r = l
h.p = l
h.v = g
m.w = l
b.w = l
assert b.w.v.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.p: A = None
        self.v: B = None
        self.txt = txt

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

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

l = A("l")
g = B("g")
f = C("f")
j = C("j")
a = B("a")
h = A("h")
m = C("m")
b = C("b")

l.r = h
l.p = h
l.v = g
g.o = a
g.z = a
g.r = h
f.w = l
j.w = l
a.o = g
a.z = g
a.r = h
h.r = l
h.p = l
h.v = g
m.w = l
b.w = l
assert b.w.v.r.p.txt == "l"