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

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

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

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

k = A("k")
m = B("m")
i = C("i")
h = D("h")
l = A("l")
e = C("e")
g = B("g")
a = C("a")
c = C("c")
f = C("f")

k.p = f
k.y = e
k.w = h
m.y = k
m.r = g
m.w = h
m.z = l
i.x = l
i.v = h
i.r = h
h.v = k
l.p = a
l.y = c
l.w = h
e.x = k
e.v = h
e.r = h
g.y = l
g.z = l
g.r = m
g.w = h
a.x = l
a.v = h
a.r = h
c.x = l
c.v = h
c.r = h
f.x = k
f.v = h
f.r = h
assert g.y.p.x.y.x.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: C = None
        self.w: D = None
        self.txt = txt

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

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

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

k = A("k")
m = B("m")
i = C("i")
h = D("h")
l = A("l")
e = C("e")
g = B("g")
a = C("a")
c = C("c")
f = C("f")

k.p = f
k.y = e
k.w = h
m.y = k
m.r = g
m.w = h
m.z = l
i.x = l
i.v = h
i.r = h
h.v = k
l.p = a
l.y = c
l.w = h
e.x = k
e.v = h
e.r = h
g.y = l
g.z = l
g.r = m
g.w = h
a.x = l
a.v = h
a.r = h
c.x = l
c.v = h
c.r = h
f.x = k
f.v = h
f.r = h
assert g.y.p.x.y.x.y.v.txt == "h"