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

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

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

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

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

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

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

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

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

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

j.o = i
j.y = b
j.w = l
j.v = e
l.r = h
g.s = l
c.x = g
c.r = g
f.r = h
e.r = h
i.o = j
i.y = b
i.w = l
i.v = f
b.x = g
b.r = g
h.s = f
assert l.r.s.r.s.r.txt == "h"