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

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

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

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

c = A("c")
h = B("h")
n = C("n")
j = D("j")
f = C("f")

c.p = f
c.z = f
h.p = j
h.v = n
n.t = f
n.x = f
n.z = c
n.r = h
j.y = c
j.p = c
j.s = h
f.t = n
f.x = n
f.z = c
f.r = h
assert j.s.v.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: C = None
        self.txt = txt

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

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

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

c = A("c")
h = B("h")
n = C("n")
j = D("j")
f = C("f")

c.p = f
c.z = f
h.p = j
h.v = n
n.t = f
n.x = f
n.z = c
n.r = h
j.y = c
j.p = c
j.s = h
f.t = n
f.x = n
f.z = c
f.r = h
assert j.s.v.t.t.txt == "n"