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

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

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

j = A("j")
d = B("d")
f = C("f")
b = A("b")
k = B("k")
g = C("g")
c = B("c")
h = A("h")
e = A("e")

j.r = h
j.v = k
d.v = c
f.p = b
f.y = g
f.r = j
b.r = j
b.v = c
k.v = d
g.p = b
g.y = f
g.r = j
c.v = d
h.r = e
h.v = d
e.r = h
e.v = c
assert g.p.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.v: B = None
        self.txt = txt

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

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

j = A("j")
d = B("d")
f = C("f")
b = A("b")
k = B("k")
g = C("g")
c = B("c")
h = A("h")
e = A("e")

j.r = h
j.v = k
d.v = c
f.p = b
f.y = g
f.r = j
b.r = j
b.v = c
k.v = d
g.p = b
g.y = f
g.r = j
c.v = d
h.r = e
h.v = d
e.r = h
e.v = c
assert g.p.r.v.txt == "k"