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

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.y: A = None
        self.t: B = None
        self.p: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.z: D = None
        self.t: C = None
        self.q: D = None
        self.v: A = None
        self.txt = txt

b = A("b")
h = B("h")
g = C("g")
k = D("k")
i = E("i")
m = B("m")

b.x = k
b.z = h
h.u = g
h.r = k
h.v = m
g.u = i
k.q = i
k.y = b
k.t = m
k.p = g
i.x = b
i.v = b
i.z = k
i.q = k
i.t = g
m.u = g
m.r = k
m.v = h
assert b.x.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.z: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: E = None
        self.y: A = None
        self.t: B = None
        self.p: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.x: A = None
        self.z: D = None
        self.t: C = None
        self.q: D = None
        self.v: A = None
        self.txt = txt

b = A("b")
h = B("h")
g = C("g")
k = D("k")
i = E("i")
m = B("m")

b.x = k
b.z = h
h.u = g
h.r = k
h.v = m
g.u = i
k.q = i
k.y = b
k.t = m
k.p = g
i.x = b
i.v = b
i.z = k
i.q = k
i.t = g
m.u = g
m.r = k
m.v = h
assert b.x.t.r.txt == "k"