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

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

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

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

b = A("b")
j = B("j")
g = C("g")
d = D("d")
n = D("n")
l = A("l")
c = C("c")
i = A("i")
k = A("k")
h = B("h")

b.q = n
b.w = j
j.w = d
j.y = b
g.t = l
g.u = n
d.x = h
d.t = j
n.x = h
n.t = j
l.q = d
l.w = j
c.t = l
c.u = d
i.q = n
i.w = h
k.q = n
k.w = j
h.w = n
h.y = b
assert j.w.t.y.w.y.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.w: B = None
        self.txt = txt

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

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

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

b = A("b")
j = B("j")
g = C("g")
d = D("d")
n = D("n")
l = A("l")
c = C("c")
i = A("i")
k = A("k")
h = B("h")

b.q = n
b.w = j
j.w = d
j.y = b
g.t = l
g.u = n
d.x = h
d.t = j
n.x = h
n.t = j
l.q = d
l.w = j
c.t = l
c.u = d
i.q = n
i.w = h
k.q = n
k.w = j
h.w = n
h.y = b
assert j.w.t.y.w.y.q.t.txt == "j"