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

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

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

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

i = A("i")
f = B("f")
j = C("j")
g = D("g")
k = D("k")
m = C("m")

i.s = g
i.p = k
f.v = m
f.y = m
j.u = m
j.w = f
g.r = f
k.r = f
m.u = j
m.w = f
assert j.w.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.p: D = None
        self.txt = txt

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

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

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

i = A("i")
f = B("f")
j = C("j")
g = D("g")
k = D("k")
m = C("m")

i.s = g
i.p = k
f.v = m
f.y = m
j.u = m
j.w = f
g.r = f
k.r = f
m.u = j
m.w = f
assert j.w.y.u.txt == "j"