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

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

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

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

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

g.r = c
g.w = j
g.x = f
f.q = m
f.t = m
i.q = j
i.v = h
c.q = g
c.u = j
h.q = c
h.v = i
j.q = g
j.u = c
m.q = f
m.t = f
assert j.q.r.u.u.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: D = None
        self.x: B = None
        self.txt = txt

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

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

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

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

g.r = c
g.w = j
g.x = f
f.q = m
f.t = m
i.q = j
i.v = h
c.q = g
c.u = j
h.q = c
h.v = i
j.q = g
j.u = c
m.q = f
m.t = f
assert j.q.r.u.u.q.x.txt == "f"