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

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

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

n = A("n")
j = B("j")
k = C("k")
d = C("d")
h = C("h")

n.r = j
n.p = j
j.x = n
k.v = n
d.v = n
h.v = n
assert h.v.r.x.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.p: B = None
        self.txt = txt

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

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

n = A("n")
j = B("j")
k = C("k")
d = C("d")
h = C("h")

n.r = j
n.p = j
j.x = n
k.v = n
d.v = n
h.v = n
assert h.v.r.x.p.x.txt == "n"