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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.o: C = None
        self.v: B = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

m = A("m")
b = B("b")
k = C("k")
c = D("c")
d = E("d")
i = F("i")
a = G("a")

m.r = c
b.t = c
b.q = c
k.w = b
k.y = a
k.z = m
c.r = m
c.w = m
c.u = a
c.q = b
d.v = k
i.o = k
i.v = b
a.x = d
assert c.u.x.v.z.r.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.o: C = None
        self.v: B = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

m = A("m")
b = B("b")
k = C("k")
c = D("c")
d = E("d")
i = F("i")
a = G("a")

m.r = c
b.t = c
b.q = c
k.w = b
k.y = a
k.z = m
c.r = m
c.w = m
c.u = a
c.q = b
d.v = k
i.o = k
i.v = b
a.x = d
assert c.u.x.v.z.r.w.r.txt == "c"