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

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.s: A = None
        self.v: D = None
        self.x: C = None
        self.txt = txt

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

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

h = A("h")
e = B("e")
b = C("b")
f = D("f")
n = C("n")
j = A("j")
m = D("m")
a = A("a")
c = A("c")
i = B("i")

h.x = i
h.r = n
e.q = n
e.s = a
e.v = m
e.x = b
b.p = c
f.p = m
f.q = j
n.p = a
j.x = i
j.r = b
m.p = f
m.q = h
a.x = i
a.r = n
c.x = e
c.r = n
i.q = n
i.s = a
i.v = m
i.x = b
assert e.x.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: C = None
        self.s: A = None
        self.v: D = None
        self.x: C = None
        self.txt = txt

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

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

h = A("h")
e = B("e")
b = C("b")
f = D("f")
n = C("n")
j = A("j")
m = D("m")
a = A("a")
c = A("c")
i = B("i")

h.x = i
h.r = n
e.q = n
e.s = a
e.v = m
e.x = b
b.p = c
f.p = m
f.q = j
n.p = a
j.x = i
j.r = b
m.p = f
m.q = h
a.x = i
a.r = n
c.x = e
c.r = n
i.q = n
i.s = a
i.v = m
i.x = b
assert e.x.p.x.txt == "e"