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

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

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

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

j = A("j")
b = B("b")
m = C("m")
d = D("d")
g = A("g")
h = C("h")
a = C("a")
i = B("i")

j.o = d
j.s = d
b.z = i
b.p = a
m.s = g
d.w = g
d.v = b
g.o = d
g.s = d
h.s = j
a.s = g
i.z = b
i.p = h
assert j.s.w.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.s: D = None
        self.txt = txt

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

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

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

j = A("j")
b = B("b")
m = C("m")
d = D("d")
g = A("g")
h = C("h")
a = C("a")
i = B("i")

j.o = d
j.s = d
b.z = i
b.p = a
m.s = g
d.w = g
d.v = b
g.o = d
g.s = d
h.s = j
a.s = g
i.z = b
i.p = h
assert j.s.w.s.v.txt == "b"