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

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

i = A("i")
l = B("l")
f = B("f")
c = A("c")
g = A("g")
h = A("h")

i.w = l
i.q = g
l.u = c
l.t = c
f.u = i
f.t = c
c.w = f
c.q = g
g.w = l
g.q = i
h.w = l
h.q = i
assert g.w.t.q.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: A = None
        self.txt = txt

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

i = A("i")
l = B("l")
f = B("f")
c = A("c")
g = A("g")
h = A("h")

i.w = l
i.q = g
l.u = c
l.t = c
f.u = i
f.t = c
c.w = f
c.q = g
g.w = l
g.q = i
h.w = l
h.q = i
assert g.w.t.q.w.u.txt == "c"