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

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

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

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

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

l.y = i
l.u = i
l.p = j
f.p = h
f.s = h
c.r = e
c.v = b
c.x = l
c.w = f
n.x = c
h.p = f
h.s = f
j.p = f
j.s = f
d.y = i
d.u = i
d.p = h
b.x = c
e.r = c
e.v = n
e.x = l
e.w = j
i.x = c
assert b.x.x.p.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.u: D = None
        self.p: B = None
        self.txt = txt

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

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

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

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

l.y = i
l.u = i
l.p = j
f.p = h
f.s = h
c.r = e
c.v = b
c.x = l
c.w = f
n.x = c
h.p = f
h.s = f
j.p = f
j.s = f
d.y = i
d.u = i
d.p = h
b.x = c
e.r = c
e.v = n
e.x = l
e.w = j
i.x = c
assert b.x.x.p.s.s.s.s.txt == "h"