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

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

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

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

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

e.y = f
e.s = c
a.x = k
a.u = b
f.v = c
b.x = h
b.s = k
h.x = b
h.s = b
k.x = b
k.s = l
l.x = k
l.s = k
d.x = k
d.u = h
g.y = f
g.s = e
c.y = f
c.s = g
assert d.x.x.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.s: A = None
        self.txt = txt

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

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

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

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

e.y = f
e.s = c
a.x = k
a.u = b
f.v = c
b.x = h
b.s = k
h.x = b
h.s = b
k.x = b
k.s = l
l.x = k
l.s = k
d.x = k
d.u = h
g.y = f
g.s = e
c.y = f
c.s = g
assert d.x.x.x.s.txt == "b"