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

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

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

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

l = A("l")
n = B("n")
c = C("c")
d = D("d")
m = A("m")
h = A("h")

l.x = d
l.p = m
l.r = h
l.w = c
n.q = h
n.o = h
n.u = d
c.y = d
c.v = n
c.t = n
c.x = l
d.s = h
m.x = d
m.p = h
m.r = h
m.w = c
h.x = d
h.p = l
h.r = m
h.w = c
assert c.v.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.p: A = None
        self.r: A = None
        self.w: C = None
        self.txt = txt

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

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

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

l = A("l")
n = B("n")
c = C("c")
d = D("d")
m = A("m")
h = A("h")

l.x = d
l.p = m
l.r = h
l.w = c
n.q = h
n.o = h
n.u = d
c.y = d
c.v = n
c.t = n
c.x = l
d.s = h
m.x = d
m.p = h
m.r = h
m.w = c
h.x = d
h.p = l
h.r = m
h.w = c
assert c.v.o.p.txt == "l"