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

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

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

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

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

j.p = d
l.y = c
e.x = j
e.q = n
e.r = d
c.p = m
c.u = j
c.v = e
a.x = m
a.q = c
a.r = e
h.p = j
h.u = j
h.v = a
f.y = h
m.p = a
n.p = j
n.u = m
n.v = d
d.x = j
d.q = h
d.r = a
assert e.x.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

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

j.p = d
l.y = c
e.x = j
e.q = n
e.r = d
c.p = m
c.u = j
c.v = e
a.x = m
a.q = c
a.r = e
h.p = j
h.u = j
h.v = a
f.y = h
m.p = a
n.p = j
n.u = m
n.v = d
d.x = j
d.q = h
d.r = a
assert e.x.p.q.txt == "h"