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

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.z: A = None
        self.x: B = None
        self.txt = txt

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

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

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

f.t = j
f.w = c
k.y = g
k.z = j
k.x = b
e.z = b
m.w = k
m.p = k
m.v = c
m.s = g
b.y = f
b.z = j
b.x = k
i.w = b
i.p = k
i.v = m
i.s = j
j.t = f
j.w = i
g.t = j
g.w = c
c.w = b
c.p = b
c.v = i
c.s = j
assert m.v.s.w.w.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.w: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.z: A = None
        self.x: B = None
        self.txt = txt

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

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

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

f.t = j
f.w = c
k.y = g
k.z = j
k.x = b
e.z = b
m.w = k
m.p = k
m.v = c
m.s = g
b.y = f
b.z = j
b.x = k
i.w = b
i.p = k
i.v = m
i.s = j
j.t = f
j.w = i
g.t = j
g.w = c
c.w = b
c.p = b
c.v = i
c.s = j
assert m.v.s.w.w.x.x.txt == "b"